Skip to content

feat: development mode with hot-reloading - #36

Merged
hulxv merged 69 commits into
metacall:masterfrom
fahdfady:development-mode
Oct 17, 2025
Merged

hulxv merged 69 commits into
metacall:masterfrom
fahdfady:development-mode

Conversation

@fahdfady

@fahdfady fahdfady commented Feb 23, 2025 •

Copy link
Copy Markdown
Collaborator

a step related to issue the development mode mentioned in issue #24
This adds

1. a new crate: metassr-watcher

2. a rebuilder module inside metassr-server crate

3. a new CLI command metassr dev

starts in package.json by building the project by running npm run build normally
enters a development mode

  1. starts a normal server using `metassr-server
  2. watches for changes in files: uses metassr-watcher crate to watcher for changes
  3. Rebuilds on change (only for pages): if the watcher detected a change, rebuild
pub enum RebuildType {
    Page(PathBuf), // this only is doe
    Layout,
    Component,
    Style,
    Static,
}

4. trigger a refresh

open a WebSocket connection

  • server: in rust, a WebSocket sends a reload message whenever there is a file change detected via metassr-watcher.
  • client: a JavaScript script injected (only in dev mode) to the html, connected to rust server, if it gets triggered reloads the page.

model

how this works:
metassr-watcher watches for a file change ==> identify a rebuild type RebuildType ==> Rebuild ==> trigger reload

@hulxv hulxv changed the title Development mode feat: develoment mode with hot-reloading Feb 23, 2025
@fahdfady
fahdfady marked this pull request as draft March 6, 2025 12:44
@hulxv hulxv changed the title feat: develoment mode with hot-reloading feat: development mode with hot-reloading Oct 6, 2025
Comment thread flake.nix
Comment thread flake.lock
Comment thread crates/metassr-bundler/Cargo.toml
Comment thread crates/metassr-server/src/lib.rs Outdated
Comment thread crates/metassr-server/src/lib.rs Outdated
Comment thread crates/metassr-server/src/lib.rs
Comment thread crates/metassr-server/src/lib.rs Outdated
Comment thread crates/metassr-server/src/lib.rs Outdated
Comment thread crates/metassr-server/src/live_reload.rs Outdated
Comment thread metassr-cli/src/cli/builder.rs Outdated
@fahdfady
fahdfady requested a review from hulxv October 9, 2025 11:22

@hulxv hulxv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but final requests

Comment thread crates/metassr-server/src/scripts/live-reload.js
Comment thread crates/metassr-server/src/lib.rs
Comment thread crates/metassr-server/src/live_reload.rs Outdated

@hulxv hulxv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last thing and it will be ready to merge

Comment thread crates/metassr-server/src/live_reload.rs Outdated
@hulxv
hulxv force-pushed the master branch 2 times, most recently from 2ea924a to ea9387a Compare October 16, 2025 17:07

@hulxv hulxv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hulxv
hulxv merged commit 84dc844 into metacall:master Oct 17, 2025
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants